import service from './config'
import type { responseConfig } from './config'

interface requestTypeGet {
  <T = any>(url: string, params?: Record<string, any>,header?:object,auth?:boolean): Promise<responseConfig<T>>
}
interface requestTypeNarmal {
  <T = any>(url: string, data?: Record<string, any>,header?:object,auth?:boolean): Promise<responseConfig<T>>
}
const get: requestTypeGet = (url, params,header,auth = true ) => {
  return service({ url: url, method: 'GET', params: params,header,auth })
}
const post: requestTypeNarmal = (url, data,header,auth = true) => {
  return service({ url: url, method: 'POST', data: data,header,auth })
}
const put: requestTypeNarmal = (url, data,header,auth = true) => {
  return service({ url: url, method: 'PUT', data: data,header,auth })
}
const deleteRequest: requestTypeNarmal = (url, data,header,auth = true) => {
  return service({ url: url, method: 'DELETE', data: data,header,auth })
}
export default {
  get,
  post,
  put,
  delete: deleteRequest,
}
